package team.lourd.network.system.telecom.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import team.lourd.network.system.telecom.domain.Permission;

import java.util.List;

/**
 * @Author: yuwenming
 * @Description:
 * @Date: Created in 17:33 2018/6/11
 */
@Repository
public interface PermissionRepository extends JpaRepository<Permission, Integer> {

    /**
     * 根据父菜单，查询子菜单
     *
     * @param parentId
     * @return
     */
    @Query(value = "select * from telecom_permission where parent_id = :parentId and permission_type = 0 order by id asc", nativeQuery = true)
    List<Permission> queryListParentId(@Param("parentId") Integer parentId);

    @Query(value = "select id from telecom_permission where permission_type = 0", nativeQuery = true)
    List<Integer> findAllPermissionId();

}
